<template>
	<view :style="colorStyle">
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="header acea-row row-middle row-between">
					<text>兑换时间：{{ item._add_time }}</text>
					<text class="quan" v-if="item.cartInfo[0].product_type == 3">券</text>
				</view>
				<view class="body">
					<image class="pic" :src="item.cartInfo[0].productInfo.image" mode="aspectFill"></image>
					<view class="content">
						<view class="title text-cut-2">{{ item.cartInfo[0].productInfo.store_name }}</view>
						<view class="spu">
							<text>{{ item.cartInfo[0].productInfo.attrInfo.suk }}</text>
							<!-- <text style="margin-left: 20rpx;">尺码：165/88A</text> -->
						</view>
					</view>
				</view>
				<view class="foot acea-row row-middle row-between">
					<view class="status">
						<text v-if="item.cartInfo[0].product_type == 3">{{ item._status._title }}</text>
					</view>
					<view class="acea-row row-middle">
						<button v-if="item.cartInfo[0].product_type == 3" class="btn" @click="copyCode(item.cartInfo[0].trade_code)">复制交易码</button>
						<button v-if="item.status != 0 && item.cartInfo[0].product_type != 3" class="btn" @tap="goPage(1, `/pages/goods/goods_logistics/index?orderId=${item.order_id}`)">查看物流</button>
						<button class="btn bg" @click="intoPage(item.order_id)">查看详情</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import colors from '@/mixins/color.js';
	import { getOrderList } from '@/api/order.js'
	export default {
		data() {
			return {
				list: []
			};
		},
		mixins:[colors],
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				getOrderList().then(res => {
					this.list = res.data
				})
			},
			intoPage(order_id) {
				uni.navigateTo({
					url: `/pages/users/user_integral/order_detail?orderId=${order_id}`
				})
			},
			goPage(type, url) {
				if (type == 1) {
					uni.navigateTo({
						url
					});
				} else if (type == 2) {
					uni.switchTab({
						url
					});
				} else if (type == 3) {
					uni.navigateBack();
				}
			},
			copyCode(val) {
				uni.setClipboardData({
					data: val
				})
			}
		}
	}
</script>

<style lang="less" scoped>
.list {
	padding: 20rpx;
	.item {
		margin-bottom: 20rpx;
		background-color: #fff;
		.header {
			padding: 30rpx;
			border-bottom: 1px solid #eee;
			.quan {
				background-color: var(--view-theme);
				color: #fff;
				font-size: 20rpx;
				padding: 5rpx 8rpx;
				border-radius: 7rpx;
			}
		}
		.body {
			display: flex;
			padding: 30rpx;
			.pic {
				width: 120rpx;
				height: 120rpx;
				margin-right: 20rpx;
				border-radius: 10rpx;
			}
			.content {
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-between;
				.spu {
					color: #999;
					font-size: 24rpx;
				}
			}
		}
		.foot {
			padding: 20rpx 30rpx;
			border-top: 1px solid #eee;
			// justify-content: flex-end;
			.status {
				color: var(--view-theme);
			}
			.btn {
				padding: 10rpx 30rpx;
				font-size: 24rpx;
				border: 1px solid #ddd;
				color: #999;
				border-radius: 70rpx;
				margin-left: 20rpx;
				line-height: 35rpx;
			}
			.bg {
				color: #fff;
				background-color: var(--view-theme);
				border-color: var(--view-theme);
			}
		}
	}
}
</style>
